feat: Phase 2 — local-LLM fallback (opt-in, human-gated)#7
Merged
Conversation
Adds llm.py: an opt-in OpenAI-compatible fallback (Open WebUI) that parses the emails the deterministic templates miss (Ryanair/Wizz/LATAM/OTAs). It runs only on files the templates didn't match, and every candidate it returns is extractor="llm" + confidence="uncertain" by construction — so classify() routes it to the human-review bucket and _blocked_reason() keeps it out of --auto-write. An LLM guess never writes itself. - populate.parse_candidates gains a per-file fallback (env LLM_FALLBACK or --llm). - Dockerfile copies llm.py (populate imports it). - 15 tests: JSON/fence parsing, provenance+confidence contract, enable gating, and the populate integration (fallback used only when templates miss). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This was referenced Jul 7, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds
llm.py, the Phase 2 fallback that parses the long tail the deterministic templates can't (Ryanair, Wizz, LATAM, OTAs) via an OpenAI-compatible endpoint (Open WebUI on the homelab box).Safety by construction
extractor="llm"+confidence="uncertain"—classify()routes it to the human-review bucket and_blocked_reason()keeps it out of the unattended--auto-writepath. An LLM guess never writes itself.LLM_FALLBACK=1andLLM_URL/LLM_MODEL(orpopulate.py --llm).Changes
llm.py— config, OpenAI-compatible/v1/chat/completionsclient, robust JSON/code-fence parsing, candidate mapping (reusesairdatafor ICAO).populate.parse_candidates— per-file fallback when the templates miss.Dockerfile— copiesllm.py(populate imports it)..env.example, README — document the opt-in.tests/test_llm.py— 15 tests (parsing, provenance/confidence contract, enable gating, populate integration). Full suite: 44 green.Needs from you before it can actually call a model: the vmgpu Open WebUI base URL, model name, and an API key (→
.env, never committed).🤖 Generated with Claude Code